# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=djvulibre

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=3.5.25.3
pkgrel=1
pkgdesc="Suite to create, manipulate and view DjVu (mingw-w64)"
arch=('any')
url="http://djvu.sourceforge.net/"
license=("GPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
    "${MINGW_PACKAGE_PREFIX}-libtiff"
    "${MINGW_PACKAGE_PREFIX}-libjpeg"
    "${MINGW_PACKAGE_PREFIX}-zlib"
    )
options=('staticlibs' 'strip')
source=("http://downloads.sourceforge.net/djvu/${_realname}-${pkgver}.tar.gz"
    djvulibre-3.5.22-exeext.patch
    djvulibre-3.5.22-msvcp60.patch
    djvulibre-3.5.23-size_t.patch
    djvulibre-3.5.25-precision.patch)
md5sums=('5f45d6cd5700b4dd31b1eb963482089b'
         '1f3f9949aa9ef1a2228512f8e928160b'
         'c9e60c5553223380faa54b9db5328cb7'
         '8cc6fcf9c449631526e5644e1600379c'
         '64ceeff2ff000a8ce1c749f796ed956c')

prepare() {
  cd "$srcdir/${_realname}-${pkgver%.*}"
  patch -p1 -i ${srcdir}/djvulibre-3.5.22-exeext.patch
  patch -p1 -i ${srcdir}/djvulibre-3.5.22-msvcp60.patch
  patch -p1 -i ${srcdir}/djvulibre-3.5.23-size_t.patch
  patch -p1 -i ${srcdir}/djvulibre-3.5.25-precision.patch
}

build() {
    mkdir -p "${srcdir}/build-${MINGW_CHOST}"
    cd "${srcdir}/build-${MINGW_CHOST}"
    "${srcdir}"/${_realname}-${pkgver%.*}/configure \
      --prefix=${MINGW_PREFIX} \
      --build=${MINGW_CHOST} \
      --host=${MINGW_CHOST} \
    --disable-static --enable-shared
    make
}

package() {
    cd "${srcdir}/build-${MINGW_CHOST}"
    make DESTDIR="$pkgdir" install
}
